//
//  AroundCell.m
//  youthNote
//
//  Created by huangrensheng on 16/5/24.
//  Copyright © 2016年 laber. All rights reserved.
//

#import "AroundCell.h"

@interface AroundCell()

@property (nonatomic, strong) UIImageView *aroundImage;

@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UILabel *subTitleLabel;

@property (nonatomic, strong) UILabel *aroundTime;

@property (nonatomic, strong) UILabel *aroundHot;

@property (nonatomic, strong) UILabel *commentLabel;

@end

@implementation AroundCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initChildViews];
        [self makeConstraints];
    }
    return self;
}

- (void)initChildViews{
//    self.aroundImage = [[UIImageView alloc] init];
//    [self.contentView addSubview:self.aroundImage];
    
    self.titleLabel = [[UILabel alloc] initWithFont:[UIFont systemFontOfSize:15] TextColor:BLACK_COLOR Text:@"两岸VR/AR产业界6月5日将在厦门举办高峰论坛"];
    [self.contentView addSubview:self.titleLabel];
    
    self.subTitleLabel = [[UILabel alloc] initWithFont:[UIFont systemFontOfSize:13] TextColor:GREY_COLOR Text:@"细数2016年中国科技创新领域的热词，VR/AR肯定是其一。海峡两岸VR/AR产业界，如今一齐把目光锁定厦门——2016两岸VR/AR产业高峰论坛将于6月5日在厦门国际会展中心国际会议厅举行。"];
    self.subTitleLabel.numberOfLines = 2;
    [self.contentView addSubview:self.subTitleLabel];
    
    self.aroundTime = [[UILabel alloc] initWithFont:[UIFont systemFontOfSize:12] TextColor:GRAYISH_COLOR Text:@"2016-01-01"];
    [self.contentView addSubview:self.aroundTime];
    
    self.aroundHot = [[UILabel alloc] initWithFont:[UIFont boldSystemFontOfSize:14] TextColor:[UIColor whiteColor] Text:@"HOT"];
    self.aroundHot.layer.cornerRadius = 4.0f;
    self.aroundHot.layer.borderWidth = 1.0f;
    self.aroundHot.layer.borderColor = RED_COLOR.CGColor;
    self.aroundHot.layer.masksToBounds = YES;
    self.aroundHot.backgroundColor = RED_COLOR;
    self.aroundHot.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.aroundHot];
    
    self.commentLabel = [[UILabel alloc] initWithFont:[UIFont systemFontOfSize:12] TextColor:GRAYISH_COLOR Text:@"500评"];
    [self.contentView addSubview:self.commentLabel];
}

- (void)makeConstraints{
    __weak typeof(self) weakSelf = self;
    
//    [self.aroundImage mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.leading.equalTo(weakSelf.contentView.mas_leading).equalTo(@8);
//        make.top.equalTo(weakSelf.contentView.mas_top).equalTo(@8);
//        make.bottom.equalTo(weakSelf.contentView.mas_bottom).equalTo(@8);
//        make.width.equalTo(@84);
//    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(weakSelf.contentView.mas_leading).equalTo(@8);
        make.top.equalTo(weakSelf.contentView.mas_top).equalTo(@8);
        make.trailing.equalTo(weakSelf.aroundHot.mas_leading).equalTo(@(-8));
    }];
    
    [self.aroundHot mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@40);
        make.trailing.equalTo(weakSelf.contentView.mas_trailing).equalTo(@(-8));
        make.top.equalTo(weakSelf.titleLabel.mas_top);
    }];
    
    [self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(weakSelf.titleLabel.mas_leading);
        make.trailing.equalTo(weakSelf.aroundHot.mas_trailing);
        make.top.equalTo(weakSelf.titleLabel.mas_bottom).equalTo(@5);
    }];
    
    [self.aroundTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.subTitleLabel.mas_bottom).equalTo(@5);
        make.trailing.equalTo(weakSelf.aroundHot.mas_trailing);
    }];
    
    [self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(weakSelf.subTitleLabel.mas_leading);
        make.top.equalTo(weakSelf.aroundTime.mas_top);
    }];
    
}

@end
